﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:controls="clr-namespace:Rabbit.Controls;assembly=Rabbit.Controls"
        xmlns:behavior="clr-namespace:MicroBlogClient.Behaviors"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <DataTemplate x:Key="MyCommentsItemTemplate">
        <DataTemplate.Resources>
            <Storyboard x:Key="YellowFade">
                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" FillBehavior="Stop">
                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFEFF76" />
                    <SplineColorKeyFrame KeyTime="00:00:20" Value="#19FEFF76" />
                </ColorAnimationUsingKeyFrames>
            </Storyboard>
        </DataTemplate.Resources>
        <DockPanel Margin="0,10,0,10" x:Name="grid" Background="Transparent">
            <!--User Picture-->
            <Border VerticalAlignment="Top" Width="40" >
                <Border BorderBrush="White" DockPanel.Dock="Left" CornerRadius="5" Height="40" Width="40" BorderThickness="1">
                    <Image Stretch="UniformToFill" 
                           behavior:CommandHelper.MouseEnter="{Binding ShowUserInformationCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                           behavior:CommandHelper.MouseEnterParameter="{Binding User}" 
                           behavior:CommandHelper.MouseLeave="{Binding HideUserInformationCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                           Source="{Binding User.ProfileImageUrl, Converter={StaticResource ImageConverter}, IsAsync=True}" />
                </Border>
            </Border>
            <!--Status Text-->
            <StackPanel Margin="10,0,0,0">
                <!--User/Status Information-->
                <StackPanel Orientation="Horizontal">
                    <TextBlock TextWrapping="Wrap" Canvas.Top="0" Width="Auto">
                        <Hyperlink CommandParameter="{Binding User.ScreenName}" 
                            Command="{Binding OpenUserPageCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}">
                            <Run Text="{Binding User.ScreenName}"/>
                        </Hyperlink>
                    </TextBlock>
                    <controls:ImageEx Visibility="{Binding User.Verified, Converter={StaticResource BooleanToVisibilityConverter}}" Source="{StaticResource CertificateUser}" Height="18" Width="20"/>
                    <TextBlock Foreground="Gray" Margin="5,0,0,0" 
                               Text="{Binding CreatedAt, Converter={StaticResource ResourceKey=DateTimeFormatConverter}, IsAsync=True}"
                               ToolTip="{Binding CreatedAt, Converter={StaticResource ResourceKey=DateTimeFormatConverter},ConverterParameter={}yyy-MM-dd HH:mm:ss,StringFormat={}发表于{0}}"
                               />
                </StackPanel>
                <!--Status Inforamtion:Text and Picture(if exist)-->
                <DockPanel Margin="10,10,0,0">
                    <!--Status text-->
                    <controls:TextBlockEx 
                        behavior:CommandHelper.OnUserNameClicked="{Binding OpenUserPageCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                        Foreground="{DynamicResource StatusForegroundBrush}"  
                        LineHeight="20" Text="{Binding Text, IsAsync=True}"
                        DockPanel.Dock="Top" TextWrapping="Wrap"/>
                </DockPanel>
                <!--Reply to status information-->
                <Border Margin="10,5,0,0" BorderBrush="{DynamicResource FowardedStatusLeftLineBrush}" BorderThickness="1,0,0,0">
                    <controls:TextBlockEx Margin="5,0,0,0"
                                    behavior:CommandHelper.OnUserNameClicked="{Binding OpenUserPageCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                                        Padding="5,0,0,0"
                                        LineHeight="20"
                                        Foreground="{DynamicResource FowardedStatusForegroundBrush}" 
                                        Text="{Binding InReplyToStatusText, IsAsync=True}" 
                                        TextWrapping="Wrap"/>
                </Border>
                <TextBlock Margin="0,10,0,0">
                        <TextBlock Text="{Binding Source}" Foreground="Gray" />
                        <TextBlock  Margin="10,0,0,0">
                            <Hyperlink CommandParameter="{Binding}"
                                      Command="{Binding ReplyToCommentsCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                                      >
                                <Run Text="回复"/></Hyperlink>
                             <Hyperlink CommandParameter="{Binding}"
                                      Command="{Binding CopyCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}">
                                 复制</Hyperlink>
                        </TextBlock>
                    </TextBlock>
            </StackPanel>
        </DockPanel>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsNew}" Value="true">
                <DataTrigger.EnterActions>
                    <BeginStoryboard Storyboard="{StaticResource YellowFade}" x:Name="YellowFade_BeginStoryboard" />
                </DataTrigger.EnterActions>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

   
</ResourceDictionary>